package com.mdz.nc.Controller;


import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mdz.nc.Entity.SysSpcrkls;
import com.mdz.nc.Mapper.SysSpcrklsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 孟德志
 * @since 2020-07-07
 */
@Controller
@RequestMapping("/nc/sysSpcrkls")
public class SysSpcrklsController {

    @Autowired
    private SysSpcrklsMapper sysSpcrklsMapper;

    @RequestMapping("/splsk")
    public String splsk(){
        return "splsk";
    }

    @ResponseBody
    @RequestMapping(value = "/getspcrklsall",method = RequestMethod.GET)
    public String getspcrklsall(@RequestParam int pageNumber, @RequestParam int pageSize, HttpServletResponse response, SysSpcrkls sysSpcrkls){
        response.setContentType("text/json");
        response.setCharacterEncoding("utf-8");
        PageHelper.startPage(pageNumber, pageSize);
        List<SysSpcrkls> ncList=sysSpcrklsMapper.selectList(null);
        PageInfo page=new PageInfo(ncList);
        List<SysSpcrkls> rows = page.getList();
        int total = (int) page.getTotal();
        JSONObject result = new JSONObject();
        result.put("rows",rows);
        result.put("total",total);
        return result.toJSONString();
    }
}

